const tagInfo = '[/libs/model/manager.js]：';
import http from '../net/request';
import apiUrls from "../net/urls";
const Manager = {
    async loginOut() {
        let url = apiUrls.loginOut;
        let param = {
        };
        let res = await http.get(url, param);
        return res;
    },
    /**
     * 修改密码
     * @param {*} orgPassword 
     * @param {*} password 
     * @param {*} repassword 
     * @returns 
     */
    async changePassword(orgPassword, password, repassword) {
        let url = apiUrls.changePassword;
        let param = {
            orgPassword,
            password,
            repassword
        };
        let res = await http.get(url, param);
        return res;
    },
    /**
     * 记录列表
     * @param {*} date 
     * @returns 
     */
    async recordIndex(date) {
        let url = apiUrls.recordIndex;
        let param = {
            date
        };
        let res = await http.get(url, param);

        let recordList = res.data.recordList;
        let allLong = 1;
        recordList.forEach((item) => {
            if (item.record_long > allLong) {
                allLong = item.record_long;
            }
        });
        recordList.forEach((item) => {
            item.percent = (item.record_long / allLong) * 100;
        });
        // this.logI(tagInfo, "recoredList", recordList);

        return res;
    },
    /**
     * 记录添加
     * @param {*} param 
     * @returns 
     */
    async recordAdd(param) {
        let url = apiUrls.recordAdd;

        let res = await http.get(url, param);
        return res;
    },
    /**
     * 编辑 记录
     * @param {*} param 
     * @returns 
     */
    async recordEdit(param) {
        let url = apiUrls.recordEdit;

        let res = await http.get(url, param);
        return res;
    },
    /**
     * 删除记录
     * @param {*} id 
     * @returns 
     */
    async recordDelete(id) {
        let url = apiUrls.recordDelete;
        let param = {
            id
        };
        let res = await http.get(url, param);
        return res;
    },
    /**
     * 分类列表
     * @returns 
     */
    async recordTypeList() {
        let url = apiUrls.recordTypeList;
        let param = {

        };
        let res = await http.get(url, param);
        return res;
    },
    async recordDetail(id) {
        let url = apiUrls.recordDetail;
        let param = {
            id
        };
        let res = await http.get(url, param);
        return res;
    },
}
export default Manager;